package com.sgb.kjwl.view.ui.fragment.enterprise;

import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.amap.api.maps.MapView;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.Marker;
import com.google.android.material.tabs.TabLayout;
import com.sgb.alimaplibrary.MapMarkerTools;
import com.sgb.kjwl.AppFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentMapSearchServiceBinding;
import com.sgb.kjwl.model.entity.ParentAreaEntity;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.model.entity.enterprise.EpQuoteEntity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalQuoteDetailActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.SearchProviderListAdapter;
import com.sgb.kjwl.view.ui.adapter.enterprise.SearchProviderMapAdapter;
import com.sgb.kjwl.view.ui.adapter.enterprise.SearchServiceListAdapter;
import com.sgb.kjwl.view.ui.adapter.enterprise.SearchServiceMapAdapter;
import com.sgb.kjwl.view.widget.EnterprisePopWindow;
import com.sgb.kjwl.view.widget.ServiceTypeSearchWindow;
import com.sgb.kjwl.viewmodel.enterprise.MapSearchServiceModel;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.util.ClickUtils;
import com.swgk.core.util.MToast;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Time:2021/5/10
 * Author:黄淋
 * Description:地图、列表切换 搜索服务/服务商
 */
public class NewMapSearchServiceFragment extends AppFragment {

    MapSearchServiceModel viewModel;
    public static final String TYPE_LIST = "列表";
    public static final String TYPE_MAP = "地图";

    public static final String TYPE_SERVICE = "找服务";
    public static final String TYPE_PROVIDER = "找服务商";

    private FragmentMapSearchServiceBinding binding;
    //右上角弹框
    private ServiceTypeSearchWindow mSearchWindow;
    //底部弹出的Adapter
    private SearchServiceMapAdapter serviceMapAdapter;
    private SearchProviderMapAdapter providerMapAdapter;
    //列表的Adapter
    private SearchServiceListAdapter serviceListAdapter;
    private SearchProviderListAdapter providerListAdapter;

    private EnterprisePopWindow mPickDistancePopWindow;//距离筛选弹窗
    private List<PickSelectEntity> mDistanceDatas = new ArrayList<>();//距离数据
    private String distanceTemp;
    public MapMarkerTools mapMarkerTools;
    private int lastPosition = -1;
    private Marker markerLast;
    private Double currentLat;
    private Double currentLong;
    private HashMap<String, Object> mMap = new HashMap();
    private EpQuoteEntity mEntity;//选中的对象

    private List<EpQuoteEntity> bundles = new ArrayList<>();
    private List<EpQuoteEntity> bundlesTemp = new ArrayList<>();

    private List<EpQuoteEntity> provider = new ArrayList<>();
    private List<EpQuoteEntity> providerTemp = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_map_search_service, container, false);
        mapMarkerTools = new MapMarkerTools(getActivity(), getLifecycle());
        initMap(savedInstanceState);
        return binding.getRoot();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        init();
    }

    protected void initView() {
        viewModel = new ViewModelProvider(this).get(MapSearchServiceModel.class);
        binding.liuhaiStatusView.setVisibility(View.VISIBLE);
        binding.mapView.setVisibility(View.VISIBLE);

        binding.ivBack.setOnClickListener(a -> getActivity().finish());
        binding.jiantouType.setOnClickListener(this);
        binding.tvDistance.setOnClickListener(this);
        binding.rightView.setOnClickListener(this);
        binding.tvServiceMap.setOnClickListener(this);
        binding.tvServiceList.setOnClickListener(this);
        binding.ivDeleteWindow.setOnClickListener(this);
        binding.itemTvWindow.setOnClickListener(this);

        initAdapter();
        initTablayout();
        initWindow();
    }

    private void initAdapter() {
        serviceMapAdapter = new SearchServiceMapAdapter(getActivity(), null);
        serviceMapAdapter.OnShowMore(companyNo ->
                WebsiteInfoActivity.start(getActivity(), companyNo, WebsiteInfoActivity.WEBSITE_FOR_COMPANY));
        providerMapAdapter = new SearchProviderMapAdapter(getActivity(), null);
        binding.demandList.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.demandList.setPullRefreshEnabled(false);
        binding.mapList.setLayoutManager(new LinearLayoutManager(getActivity()));
        serviceListAdapter = new SearchServiceListAdapter(getActivity(), null);
        providerListAdapter = new SearchProviderListAdapter(getActivity(), null);

        serviceListAdapter.setOnItemClick(new AdapterOnItemClick<EpQuoteEntity>() {
            @Override
            public void onItemClick(EpQuoteEntity entity, int position) {
                ProfessionalQuoteDetailActivity.start(getContext(), Long.parseLong(entity.getId()));
            }
        });
        providerListAdapter.setOnItemClick(new AdapterOnItemClick<EpQuoteEntity>() {
            @Override
            public void onItemClick(EpQuoteEntity entity, int position) {
                WebsiteInfoActivity.start(getActivity(), entity.getCompanyNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
            }
        });
    }

    private void initMap(Bundle savedInstanceState) {
        MapView mMapView = binding.mapView;
        mapMarkerTools.init(savedInstanceState, mMapView);
        mapMarkerTools.setMarkerClick(new MapMarkerTools.MarkerClick() {

            @Override
            public void onMarkerClick(int pos, String title) {
                Log.e("222222", "2222222-===" + pos);
            }

            @Override
            public void onMarkerClick(int pos, String title, Marker marker) {
                if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                    showServiceMarkerView(title);
                    BitmapDescriptor bitmapSmall = BitmapDescriptorFactory.fromView(setMarkStyle(Integer.valueOf(title), marker, true));
                    marker.setIcon(bitmapSmall);
                    if (lastPosition == Integer.valueOf(title)) {
                        return;
                    }
                    resetServiceMarker(marker.getId());
                } else {
                    showProviderMarkerView(title);
                    BitmapDescriptor bitmapSmall = BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.wt_pub_big));
                    marker.setIcon(bitmapSmall);
                    if (lastPosition == Integer.valueOf(title)) {
                        return;
                    }
                    resetMarker();
                }
                markerLast = marker;
                lastPosition = Integer.valueOf(title);
                mapMarkerTools.jumpPoint(marker);
            }

            @Override
            public void onLocationChanged(Double Lat, Double Log, String address) {
                if (currentLat == null || currentLat <= 0) {
                    currentLat = Lat;
                    currentLong = Log;
                    //设置经纬度以查询地图模式下的数据
                    mMap.put("latitude", currentLat);
                    mMap.put("longitude", currentLong);
                    if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                        viewModel.getServiceList(getContext(), mMap);
                    } else {
                        viewModel.getProviderList(getContext(), mMap);
                    }
                    cameraToPosition();
                }
            }

            @Override
            public void getAddress(Double Lat, Double Log, String address) {

            }

            @Override
            public void failure() {
                if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
//                    viewModel.getSupplierListModel(conditionMap, false);
                } else {
//                    viewModel.getGoodsModel(conditionMap, false);
                }
            }
        });
    }

    //设置定位点
    private void cameraToPosition() {
        mapMarkerTools.setMyLocation(currentLat, currentLong);
    }


    private View setMarkStyle(int pos, Marker marker, boolean isBigMarkView) {
        View markerView = LayoutInflater.from(getActivity()).inflate(com.sgb.alimaplibrary.R.layout.view_marker, null);
        ImageView imageView = markerView.findViewById(com.sgb.alimaplibrary.R.id.marker);
        TextView textView = markerView.findViewById(com.sgb.alimaplibrary.R.id.text);
        textView.setText(pos + 1 + "");
        Drawable drawable = getResources().getDrawable(isBigMarkView ? com.sgb.alimaplibrary.R.drawable.marker_big : com.sgb.alimaplibrary.R.drawable.marker);
        int smallFontSize = (int) getResources().getDimension(com.sgb.alimaplibrary.R.dimen.sp5);
        int bigFontSize = (int) getResources().getDimension(com.sgb.alimaplibrary.R.dimen.sp8);
        textView.setTextSize(isBigMarkView ? bigFontSize : smallFontSize);
        imageView.setImageDrawable(drawable);
        return markerView;
    }


    private void resetServiceMarker(String curMarkerId) {
        if (null != markerLast) {
            if (!TextUtils.equals(curMarkerId, markerLast.getId())) {
                markerLast.setIcon(BitmapDescriptorFactory.fromView(setMarkStyle(lastPosition, markerLast, false)));
            }
        }

    }

    private void resetMarker() {
        if (null != markerLast) {
            BitmapDescriptor bitmapSmall = BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.wt_pub));
            markerLast.setIcon(bitmapSmall);
        }

    }

    private void initWindow() {
        mSearchWindow = new ServiceTypeSearchWindow(getActivity());
        mSearchWindow.setOnClickCallBack(new ServiceTypeSearchWindow.OnClickCallBack() {
            @Override
            public void service() {
                viewModel.getServiceList(getContext(), mMap);
                binding.showList.setVisibility(View.GONE);
                binding.rightView.setText("找服务");
                binding.itemTvWindow.setText("查看详情");
            }

            @Override
            public void provider() {
                viewModel.getProviderList(getContext(), mMap);
                binding.showList.setVisibility(View.GONE);
                binding.rightView.setText("找服务商");
                binding.itemTvWindow.setText("进入企业");

            }
        });
        mSearchWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
            @Override
            public void disMiss() {
                binding.jiantouType.setImageResource(R.mipmap.shangjiantou_down);
            }
        });


        //距离
        mPickDistancePopWindow = new EnterprisePopWindow(getActivity());
        mPickDistancePopWindow.setBgView(binding.grayLayout);
        mPickDistancePopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                distanceTemp = (String) key2;
                binding.showList.setVisibility(View.GONE);
                mMap.put("distance", (String) key1);
                if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                    viewModel.getServiceList(getContext(), mMap);
                } else {
                    viewModel.getProviderList(getContext(), mMap);
                }
            }
        });

        mPickDistancePopWindow.setOnDisMissClick(() -> {
            if (null == distanceTemp || distanceTemp.equals("不限") || distanceTemp.equals("")) {
                binding.tvDistance.contentSelect(false, false);
            } else {
                binding.tvDistance.contentSelect(true, false);
            }
        });
    }

    private void initTablayout() {
        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                binding.showList.setVisibility(View.GONE);
                mMap.put("serviceClass", tab.getTag());
                if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                    viewModel.getServiceList(getContext(), mMap);
                } else {
                    viewModel.getProviderList(getContext(), mMap);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

    }

    protected void init() {
        viewModel.getServiceType();
        viewModel.serviceCategory.observe(getViewLifecycleOwner(), this::showTypeView);
        viewModel.serviceList.observe(getViewLifecycleOwner(), a -> {
            showServiceList(a);
            addMarkInfoWindow(a);
        });
        viewModel.providerList.observe(getViewLifecycleOwner(), a -> {
            showProviderList(a);
            addProviderMarkInfoWindow(a);
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.jiantou_type:
                binding.jiantouType.setImageResource(R.mipmap.shangjiantou);
                mSearchWindow.showPopwindow(binding.rightView, true, -15);
                break;
            case R.id.tv_distance://距离选择
                binding.tvDistance.contentSelect(false, true);
                if (mDistanceDatas == null || mDistanceDatas.size() == 0) {
                    viewModel.getDistanceModel();
                    viewModel.distanceList.observe(this, this::showDistancePopWindow);
                } else {
                    mPickDistancePopWindow.showPopwindowGoods(binding.selectLayout);
                }
                break;
            case R.id.right_view:
                if (!ClickUtils.isDoubleClick()) {
                    binding.showList.setVisibility(View.GONE);
                    mMap.put("serviceName", binding.etView.getText().toString().trim());
                    if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                        viewModel.getServiceList(getContext(), mMap);
                    } else {
                        viewModel.getProviderList(getContext(), mMap);
                    }
                }
                break;
            case R.id.tv_service_map://地图
                if (binding.flMap.getVisibility() == View.GONE) {
                    binding.flList.setVisibility(View.GONE);
                    binding.flMap.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.tv_service_list://列表
                if (binding.flList.getVisibility() == View.GONE) {
                    binding.flList.setVisibility(View.VISIBLE);
                    binding.flMap.setVisibility(View.GONE);
                }
                break;
            case R.id.iv_delete_window://关闭
                binding.showList.setVisibility(View.GONE);
                break;
            case R.id.item_tv_window://弹窗按钮
                if (!ClickUtils.isDoubleClick()) {
                    if (TYPE_SERVICE.equals(binding.rightView.getText().toString())) {
                        //查看详情
                        if (mEntity != null) {
                            ProfessionalQuoteDetailActivity.start(getContext(), Long.parseLong(mEntity.getId()));
                        }
                    } else {
                        //进入企业
                        if (mEntity != null) {
                            WebsiteInfoActivity.start(getActivity(), mEntity.getCompanyNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
                        }
                    }
                }
                break;
        }

    }

    /**
     * 在地图绘制服务数据位置
     *
     * @param datas
     */
    private void addMarkInfoWindow(List<EpQuoteEntity> datas) {
        try {
            mapMarkerTools.mapClear();
            bundles.clear();
            if (datas.size() == 0 && binding.flMap.getVisibility() == View.VISIBLE) {
                MToast.showToast(getActivity(), "无相关数据哦");
                return;
            }

            bundles.addAll(datas);
            bundlesTemp = datas;
            for (int i = 0; i < bundlesTemp.size(); i++) {
                EpQuoteEntity entityTemp = bundlesTemp.get(i);
                if (null != entityTemp && !TextUtils.isEmpty(entityTemp.getLatitude()) && !TextUtils.isEmpty(entityTemp.getLongitude())) {
                    double currentLatTemp = Double.parseDouble(entityTemp.getLatitude());
                    double currentLongTemp = Double.parseDouble(entityTemp.getLongitude());
                    for (int j = bundlesTemp.size() - 1; j > i; j--) {
                        EpQuoteEntity entity = bundlesTemp.get(j);
                        if (null != entity && !TextUtils.isEmpty(entity.getLatitude()) && !TextUtils.isEmpty(entity.getLongitude())) {
                            double currentLat = Double.parseDouble(entity.getLatitude());
                            double currentLong = Double.parseDouble(entity.getLongitude());
                            if (currentLatTemp == currentLat && currentLongTemp == currentLong) {
                                bundlesTemp.remove(bundlesTemp.get(j));
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < bundlesTemp.size(); i++) {
                EpQuoteEntity entity = bundlesTemp.get(i);
                if (null != entity && !TextUtils.isEmpty(entity.getLatitude()) && !TextUtils.isEmpty(entity.getLongitude())) {
                    double currentLat = Double.parseDouble(entity.getLatitude());
                    double currentLong = Double.parseDouble(entity.getLongitude());
                    if (currentLat == 0 || currentLong == 0) {
                        return;
                    }
                    mapMarkerTools.addPoiItem(currentLat, currentLong, "");
                }
            }

            mapMarkerTools.addAllMarkerToMap(0, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 在地图绘制服务商数据位置
     *
     * @param datas
     */
    private void addProviderMarkInfoWindow(List<EpQuoteEntity> datas) {
        try {
            mapMarkerTools.mapClear();
            provider.clear();
            if (datas.size() == 0 && binding.flMap.getVisibility() == View.VISIBLE) {
                MToast.showToast(getActivity(), "无相关数据哦");
                return;
            }

            provider.addAll(datas);
            providerTemp = datas;
            for (int i = 0; i < providerTemp.size(); i++) {
                EpQuoteEntity entityTemp = providerTemp.get(i);
                if (null != entityTemp && !TextUtils.isEmpty(entityTemp.getLatitude()) && !TextUtils.isEmpty(entityTemp.getLongitude())) {
                    double currentLatTemp = Double.parseDouble(entityTemp.getLatitude());
                    double currentLongTemp = Double.parseDouble(entityTemp.getLongitude());
                    for (int j = providerTemp.size() - 1; j > i; j--) {
                        EpQuoteEntity entity = providerTemp.get(j);
                        if (null != entity && !TextUtils.isEmpty(entity.getLatitude()) && !TextUtils.isEmpty(entity.getLongitude())) {
                            double currentLat = Double.parseDouble(entity.getLatitude());
                            double currentLong = Double.parseDouble(entity.getLongitude());
                            if (currentLatTemp == currentLat && currentLongTemp == currentLong) {
                                providerTemp.remove(providerTemp.get(j));
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < providerTemp.size(); i++) {
                EpQuoteEntity entity = providerTemp.get(i);
                if (null != entity && !TextUtils.isEmpty(entity.getLatitude()) && !TextUtils.isEmpty(entity.getLongitude())) {
                    double currentLat = Double.parseDouble(entity.getLatitude());
                    double currentLong = Double.parseDouble(entity.getLongitude());
                    if (currentLat == 0 || currentLong == 0) {
                        return;
                    }
                    mapMarkerTools.addPoiItem(currentLat, currentLong, "");
                }
            }
            mapMarkerTools.addAllMarkerToMap(R.mipmap.wt_pub, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 顶部tab添加数据
     *
     * @param list
     */
    public void showTypeView(List<ParentAreaEntity<List<ParentAreaEntity<List<ParentAreaEntity>>>>> list) {
        for (ParentAreaEntity entity : list) {
            TabLayout.Tab newTab = binding.tabLayout.newTab();
            newTab.setText(entity.getName());
            newTab.setTag(entity.getId());
            binding.tabLayout.addTab(newTab);
        }
    }

    /**
     * 距离筛选弹窗
     *
     * @param distanceList
     */
    private void showDistancePopWindow(List<PickSelectEntity> distanceList) {
        this.mDistanceDatas = distanceList;
        mPickDistancePopWindow.showPopwindowGoods(binding.selectLayout);
        mPickDistancePopWindow.setData(distanceList);
    }

    /**
     * 点击marker查看服务
     *
     * @param title
     */
    private void showServiceMarkerView(String title) {
        EpQuoteEntity entity = bundlesTemp.get(Integer.valueOf(title));
        mEntity = entity;
        List<EpQuoteEntity> tempList = new ArrayList<>();
        ArrayList<String> companyName = new ArrayList<>();
        for (int i = 0; i < bundles.size(); i++) {
            String tempLatitude = bundles.get(i).getLatitude();
            String tempLongitude = bundles.get(i).getLongitude();
            if (entity.getLatitude().equals(tempLatitude) && entity.getLongitude().equals(tempLongitude) && !companyName.contains(bundles.get(i).getCompanyNo())) {
                companyName.add(bundles.get(i).getCompanyNo());
                tempList.add(bundles.get(i));
            }
        }
        binding.showList.setVisibility(View.VISIBLE);
        serviceMapAdapter.setDatas(tempList);
        binding.mapList.setAdapter(serviceMapAdapter);
        serviceMapAdapter.setOnItemClick(new AdapterOnItemClick<EpQuoteEntity>() {
            @Override
            public void onItemClick(EpQuoteEntity entity, int position) {
                ProfessionalQuoteDetailActivity.start(getContext(), Long.parseLong(entity.getId()));
            }
        });
    }

    /**
     * 点击marker查看服务商
     *
     * @param title
     */
    private void showProviderMarkerView(String title) {
        EpQuoteEntity entity = providerTemp.get(Integer.valueOf(title));
        mEntity = entity;
        ArrayList<String> companyName = new ArrayList<>();
        List<EpQuoteEntity> tempList = new ArrayList<>();
        for (int i = 0; i < provider.size(); i++) {
            String tempLatitude = provider.get(i).getLatitude();
            String tempLongitude = provider.get(i).getLongitude();
            if (entity.getLatitude().equals(tempLatitude) && entity.getLongitude().equals(tempLongitude) && !companyName.contains(provider.get(i).getCompanyNo())) {
                companyName.add(provider.get(i).getCompanyNo());
                tempList.add(provider.get(i));
            }
        }
        binding.showList.setVisibility(View.VISIBLE);
        providerMapAdapter.setDatas(tempList);
        binding.mapList.setAdapter(providerMapAdapter);
        providerMapAdapter.setOnItemClick(new AdapterOnItemClick<EpQuoteEntity>() {
            @Override
            public void onItemClick(EpQuoteEntity entity, int position) {
                WebsiteInfoActivity.start(getActivity(), entity.getCompanyNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
            }
        });
    }


    /**
     * 服务列表展示
     *
     * @param datas
     */
    public void showServiceList(List<EpQuoteEntity> datas) {
        binding.demandList.setAdapter(serviceListAdapter);
        if (datas.size() == 0) {
            binding.emptyView.setVisibility(View.VISIBLE);
            binding.demandList.setLoadingMoreEnabled(false);
            binding.demandList.setVisibility(View.GONE);
        } else {
            binding.demandList.setVisibility(View.VISIBLE);
            binding.emptyView.setVisibility(View.GONE);
            binding.demandList.setLoadingMoreEnabled(true);
        }
        serviceListAdapter.setDatas(datas);
    }

    /**
     * 服务商列表展示
     *
     * @param datas
     */
    public void showProviderList(List<EpQuoteEntity> datas) {
        binding.demandList.setAdapter(providerListAdapter);
        if (datas.size() == 0) {
            binding.emptyView.setVisibility(View.VISIBLE);
            binding.demandList.setLoadingMoreEnabled(false);
            binding.demandList.setVisibility(View.GONE);
        } else {
            binding.demandList.setVisibility(View.VISIBLE);
            binding.emptyView.setVisibility(View.GONE);
            binding.demandList.setLoadingMoreEnabled(true);
        }
        providerListAdapter.setDatas(datas);
    }
}
